<template>
  <div class="app-container">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="图文分享" name="1">
        <software-share v-if="isRouterAlive"></software-share>
      </el-tab-pane>
      <el-tab-pane label="链接分享" name="2">
        <link-share v-if="isContactAlive"></link-share>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import { getSoftwareShareInfo, getLinkShareInfo } from "@/api/shuiyin/shuiyin";
import softwareShare from './components/softwareShare';
import linkShare from './components/linkShare';
export default {
  name: 'Share',
  components: {
    softwareShare,
    linkShare
  },
  data() {
    return {
      // 图文分享显示隐藏
      isRouterAlive: true,
      // 链接分享显示隐藏
      isContactAlive: false,
      // 选项卡默认选中
      activeName: '1',
      form: {
        text: ''
      }
    }
  },
  created() {
    // this.getInfo();
  },
  methods: {
    // 图文分享详情
    getInfo() {
      getSoftwareShareInfo().then((response) => {
        console.log(response)
      })
    },

    // 链接分享详情
    getLinkInfo() {
      getLinkShareInfo().then(response => {
        console.log(response)
      })
    },

    handleClick(tab, event) {
      console.log(tab, event);
      this.activeName = tab.name;
      if (tab.name === '1') {
        this.isRouterAlive = true;
        this.isContactAlive = false;
        this.getInfo();
      } else if (tab.name === '2') {
        this.isRouterAlive = false;
        this.isContactAlive = true;
        this.getInfo();
      }
    }
  }
}
</script>
